package com.alstudio.utils.android.notification;

import android.app.NotificationManager;
import android.content.Context;
import android.graphics.BitmapFactory;

import com.alstudio.ui.base.BaseActivity;
import com.alstudio.utils.activity.ALActivityManager.ActivityLifeCycleListener;
import com.alstudio.utils.android.notification.ALNotification.ALNotificationType;
import com.loovee.imaohu.R;

public class ALNotificationCenterManager implements ActivityLifeCycleListener {

	private Context mContext;

	private NotificationManager mManager;

	/**
	 * 
	 */
	public ALNotificationCenterManager(Context context) {
		// TODO Auto-generated constructor stub
		this.mContext = context;
		mManager = (NotificationManager) mContext
				.getSystemService(Context.NOTIFICATION_SERVICE);
	}

	public NotificationManager getAndroidNotificationManager() {
		return mManager;
	}

	public void showNotification(ALNotification notification) {
		getAndroidNotificationManager().notify(notification.getId(),
				notification.build());
	}

	public void cancelNotification(int id) {
		getAndroidNotificationManager().cancel(id);
	}

	public void cancelAllNotification() {
		mManager.cancelAll();
	}

	public void cancelNotification(ALNotification notification) {
		getAndroidNotificationManager().cancel(notification.getId());
	}
	

	public ALNotification showNotification(boolean old) {
		ALNotification builder = new ALNotification(mContext,
				ALNotificationType.AL_NOTIFICATION_TYPE_PROGRESS, "准备开始下载了");
		builder.setAutoCancel(true);
		builder.setContentTitle("新通知方法测试标题");
		builder.setContentText("这事新同志方法测试");
		builder.setContentInfo("这个我也不知道说什么好 ");
		builder.setSmallIcon(R.drawable.bar_icon_back);
		builder.setLargeIcon(BitmapFactory.decodeResource(
				mContext.getResources(), R.drawable.bar_icon_back));
		builder.setId(10086);

		builder.setNumber(10);
		builder.setContentIntent(ALNotification.backToApp(mContext));
		builder.setProgress(100, 0, false);

		getAndroidNotificationManager()
				.notify(builder.getId(), builder.build());

		return builder;
	}

	public ALNotification showALNotification() {
		getAndroidNotificationManager().cancelAll();

		ALNotification n = new ALNotification(mContext,
				ALNotificationType.AL_NOTIFICATION_TYPE_NORMAL, "这个是时间");

		n.setAutoCancel(true);
		n.setContentTitle("测试测试");
		n.setContentText("我在测试新方法");
		n.setWhen(System.currentTimeMillis());
		n.setSmallIcon(R.drawable.login_bt_on);
		n.setContentIntent(ALNotification.backToApp(mContext));
		n.setId(10086);

		n.setShowing(true);
		showNotification(n);

		return n;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.alstudio.utils.ALActivityManager.ActivityLifeCycleListener#
	 * onActivityCreate(com.alstudio.ui.base.BaseActivity)
	 */
	@Override
	public void onActivityCreate(BaseActivity actvity) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.alstudio.utils.ALActivityManager.ActivityLifeCycleListener#
	 * onActivityStart(com.alstudio.ui.base.BaseActivity)
	 */
	@Override
	public void onActivityStart(BaseActivity actvity) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.alstudio.utils.ALActivityManager.ActivityLifeCycleListener#
	 * onActivityResume(com.alstudio.ui.base.BaseActivity)
	 */
	@Override
	public void onActivityResume(BaseActivity actvity) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.alstudio.utils.ALActivityManager.ActivityLifeCycleListener#
	 * onActivityPause(com.alstudio.ui.base.BaseActivity)
	 */
	@Override
	public void onActivityPause(BaseActivity actvity) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.alstudio.utils.ALActivityManager.ActivityLifeCycleListener#onActivityStop
	 * (com.alstudio.ui.base.BaseActivity)
	 */
	@Override
	public void onActivityStop(BaseActivity actvity) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.alstudio.utils.ALActivityManager.ActivityLifeCycleListener#
	 * onActivityFinish(com.alstudio.ui.base.BaseActivity)
	 */
	@Override
	public void onActivityFinish(BaseActivity actvity) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.alstudio.utils.ALActivityManager.ActivityLifeCycleListener#
	 * onActivityDestroy(com.alstudio.ui.base.BaseActivity)
	 */
	@Override
	public void onActivityDestroy(BaseActivity actvity) {
		// TODO Auto-generated method stub

	}

}
